<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .login{
            width: 250px;
            border: 1px red solid;
            padding: 10px;
        }
        input{
            margin-top: 10px;
        }
        button{
            margin-top: 10px;
            margin-bottom: 20px;
        }
        .active{
            background-color: sandybrown;
            color: seashell;
        }
    </style>
</head>
<body>
    
    <div id="app">
        <!-- 第二，定义路由路径 -->
        <router-link to="/img" tag="button">扫码登录</router-link>
        <router-link to="/pwd" tag="button">密码登录</router-link>
        <br>
        <!-- 第三，给组件占位置 -->
        <router-view></router-view>
    </div>

    <template id="login-img">
        <div>
            <img src="../lib/image/04.jpg" alt="">
        </div>
    </template>
    <template id="login-pwd">
        <div class="login">
            用户名：<input type="text" ><br>
            密码：<input type="password">
            <button>登录</button>
        </div>
    </template>

    <script src="../lib/Vue/vue.js"></script>
    <script src="../lib/Vue/vue-router.js"></script>
    <!-- 第一，引入路由js文件 -->
    <script>

        var LoginImg = {
            template: '#login-img'
        }
        var LoginPwd = {
            template: '#login-pwd'
        }

        // 第四，配置路由表
        var routes = [
            {
                path: '/',
                component: LoginImg
            },
            {
                path: '/img',
                component: LoginImg
            },
            {
                path: '/pwd',
                component: LoginPwd
            }
        ]

        // 第五，实例化一个路由

        var router = new VueRouter({
            // routers: routers // 挂载路由表
            routes,
            linkActiveClass: 'active'
        })

        // 在Vue实例上挂载路由实例
        var vm = new Vue({
            el: '#app',
            // router: router 
            router,
        })
    </script>
</body>
</html>